﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LootTable : MonoBehaviour
{
    [SerializeField]
    protected Loot[] loot;
    protected List<Item> droppedItems=new List<Item>();
    protected bool gotRolled=false;
    protected virtual void RollLoot()
    {

        foreach (Loot item in loot)
        {
            int luck = Random.Range(0, 100);
            if (luck <= item.MyDropChanse)
            {
                droppedItems.Add(item.MyItem);
            }
        }
        gotRolled = true;
    }

    public virtual void ShowLoot()
    {
        if (!gotRolled)
        {
            RollLoot();
        }

        LootWindow.MyInstance.CreatePages(droppedItems);
      
    }
}
